/*
 * usea, Copyright 2011 André König
 * Hochschule Bremen - University of Applied Sciences - All Rights Reserved.
 *
 * $Id: App.java 17 2011-07-06 06:51:01Z andre.koenig $
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 *
 * Contact:
 *     André König: akoenig@stud.hs-bremen.de
 * 
 * Web:
 *     http://tutorium-prog2.tumblr.com
 * 
 */
package de.hochschule.bremen.usea.server;

import java.io.IOException;
import java.net.UnknownHostException;

import de.hochschule.bremen.usea.server.net.ServerMethodsImpl;
import de.root1.simon.exceptions.NameBindingException;

public class App {
	
	public static void main(String args[]) {
		try {
			
			// 1. Schritt: Starten des Servers
			new ServerMethodsImpl("usea", 50001);

			// 2. Schritt: Ausgabe der "Welcome message" nach Start des Servers.
			App.printWelcomeMessage();
			
		} catch (UnknownHostException e) {
			printError(e.getMessage());
		} catch (IOException e) {
			printError(e.getMessage());
			e.printStackTrace();
		} catch (NameBindingException e) {
			printError(e.getMessage());
		}
	}

	/**
	 * Ausgabe des Server "Welcome message".
	 *
	 */
	private static void printWelcomeMessage() {
		System.out.println("= The 'usea' server!!");
		System.out.println();
		System.out.println("= Cool! Der 'usea'-Server wurde gestartet.");
		System.out.println();
		System.out.println("= Warte auf Anfragen ...");
		System.out.println("---------------------------------------------");
		System.out.println();
	}

	/**
	 * Formatierung einer Fehlermeldung und Ausgabe auf der Konsole.
	 * 
	 * @param message Die Fehlermeldung.
	 *
	 */
	private static void printError(String message) {
		System.err.println("[ERROR] Der Server meldet ein Problem: "+message);
	}
}